package com.dexgdx.game.structure.projectile;

import com.badlogic.gdx.graphics.g2d.ParticleEffectPool.PooledEffect;
import com.dexgdx.game.Game;
import com.dexgdx.game.constants.EObjectId;
import com.dexgdx.game.manager.ParticleManager;
import com.dexgdx.game.structure.base.BaseRegion;
import com.dexgdx.game.structure.base.MobileObject;

public class DexMissileObject extends MobileObject{

	private static final long serialVersionUID = 8964321500584743195L;
	
	private PooledEffect pooledEffect; 
	
	public static DexMissileObject instanceFromRegion(BaseRegion baseRegion){
		return new DexMissileObject(baseRegion.x, baseRegion.y, baseRegion.height, baseRegion.width);
	}

	public DexMissileObject(float x, float y, float height, float width) {
		super(x, y, height, width, Game.defaultConstants.getDexMissileSpeed(), false, true, EObjectId.DEX_MISSILE.getObjectId());
		initialize();
	}
	
	private void initialize(){
		pooledEffect = ParticleManager.obtainFromDexMissileParticleEffectPool();
		setPooledEffectPosition();

	    float pScale = 0.2f;
	    
	    float scaling = pooledEffect.getEmitters().get(0).getScale().getHighMax();
	    pooledEffect.getEmitters().get(0).getScale().setHigh(scaling * pScale);

	    scaling = pooledEffect.getEmitters().get(0).getScale().getLowMax();
	    pooledEffect.getEmitters().get(0).getScale().setLow(scaling * pScale);
	}
	
	public PooledEffect getPooledEffect() {
		return pooledEffect;
	}

	@Override
	public boolean hasFinalizedMoving(){
		return pooledEffect.isComplete();
	}
	
	public void setPooledEffectPosition(){
		pooledEffect.setPosition(x + width / 2, y - 10);
	}
	
	public void setPooledEffectPositionInvisible(){
		pooledEffect.setPosition(-1000, y);
	}
}
